import {
	addVote,
	addOption,
	getVote,
	castVote,
	deleteVote,
	addIdea,
	getIdea,
	agreeIdea
} from '@/api'

const state = {}

const mutations = {}

const actions = {
	// 插入投票第一步
	async addVote({commit}, body){
		const res = await addVote(body)
		return res
	},
	// 插入投票第一步
	async addOption({commit}, body){
		const res = await addOption(body)
		return res
	},
	// 查询投票
	async getVote({commit}, query){
		const res = await getVote(query)
		return res
	},
	// 投票
	async castVote({commit}, body){
		const res = await castVote(body)
		return res
	},
	// 删除投票
	async deleteVote({commit}, body){
		const res = await deleteVote(body)
		return res
	},
	// 发布意见
	async addIdea({commit}, body){
		const res = await addIdea(body)
		return res
	},
	// 查询意见
	async getIdea({commit}){
		const res = await getIdea()
		return res
	},
	// 点赞意见
	async agreeIdea({commit}, body){
		const res = await agreeIdea(body)
		return res
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}